package com.mpyy.dao.everyday;

import com.mpyy.pojo.ProductInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ProductInfoDao {
    /**
     * 根据模糊查询供应商信息
     * @param proTypeId
     * @param page
     * @param limit
     * @return
     */
    @Select(" SELECT proId,proName,proAlias,proTypeName,proVulgo,unitId,proSize,agentiaId,proKeepDate,proBid," +
            "proSalePrice,warehouseId,manufacturerId,proPostil,proBarCodes,proStockLower,proComment FROM product_info a," +
            "product_type b WHERE a.proTypeId=b.proTypeId AND b.proTypeId>#{proTypeId} LIMIT #{page},#{limit}\n")
    @Result(property = "proTypeId",column = "proTypeId",id = true)
    public List<ProductInfo> all(@Param("proTypeId") String proTypeId, @Param("page") int page, @Param("limit") int limit);

    @Select("SELECT proId,proName,proAlias,a.proTypeName,proVulgo,unitId,proSize,agentiaId,proKeepDate,proBid," +
            "proSalePrice,warehouseId,manufacturerId,proPostil,proBarCodes,proStockLower,proComment FROM product_type a," +
            "product_type b,product_info c WHERE b.proTypeId=#{proTypeId} AND a.proLevelParId=b.proTypeId AND a.proTypeId=c.proTypeId LIMIT #{page},#{limit}\n  ")
    @Result(property = "proTypeId",column = "proTypeId",id = true)
    public List<ProductInfo> second(@Param("proTypeId") int proTypeId, @Param("page") int page, @Param("limit") int limit);


    @Select("SELECT proId,proName,proAlias,proTypeName,proVulgo,unitId,proSize,agentiaId,proKeepDate,proBid," +
            "proSalePrice,warehouseId,manufacturerId,proPostil,proBarCodes,proStockLower,proComment FROM product_info a," +
            "product_type b WHERE  a.proTypeId=#{proTypeId} AND b.proTypeId=#{proTypeId} LIMIT #{page},#{limit}\n" +
            "  ")
    @Result(property = "proTypeId",column = "proTypeId",id = true)
    public List<ProductInfo> tertiary(@Param("proTypeId") int proTypeId, @Param("page") int page, @Param("limit") int limit);
}
